package com.candy.control;

import com.candy.dao.DBHelper;
import com.candy.modal.UserLoginModal;
import com.candy.pojo.supplier;
import com.candy.pojo.users;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "SuppRegister")
public class SuppRegister extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String userName= request.getParameter("userName");
        String userPwd= request.getParameter("userPwd");
        String comName=request.getParameter("comName");
        String phone=request.getParameter("phone");
        String opdate=request.getParameter("opdate");
        System.out.println("注册的用户名："+userName+"，注册的密码："+userPwd);
        UserLoginModal userM=new UserLoginModal();
        String strSql="select * from users where uid='"+userName+"' and pwd='"+userPwd+"'";
        boolean isok=userM.isLogined(strSql);
        supplier supp = new supplier(userName,userPwd,comName,phone,opdate);
        String strSql1 = "INSERT INTO supplier(sid,s_pwd,s_name,s_phone,optime) VALUES(?,?,?,?,?);";
        DBHelper db=new DBHelper();
        db.addsupp(supp,strSql1);
        request.getRequestDispatcher("slogin.jsp").forward(request,response);

    }
}
